﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using VIBlend.WPF.Controls;

namespace AnonsaiWPF.CSharp.Buttons
{
    public partial class ButtonDemo : Window, IWindow
    {
        VIBlend.WPF.Controls.Button selectedButton;
        
        public ButtonDemo()
        {
            InitializeComponent();
            this.selectedButton = this.Button1;
        }

        public void DetachContent()
        {
            RemoveLogicalChild(Content);
        }

        public void SetTheme()
        {
        }

        public Grid Root
        {
            get
            {
                return this.RootVisual;
            }
        }

        private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.comboBox1 == null)
                return;

            switch (comboBox1.SelectedIndex)
            {
                case 0:
                    this.selectedButton = this.Button1;
                    break;
                case 1:
                    this.selectedButton = this.button2;
                    break;
                case 2:
                    this.selectedButton = this.button3;
                    break;
                case 3:
                    this.selectedButton = this.button4;
                    break;
                case 4:
                    this.selectedButton = this.button5;
                    break;

            }

        }

        private void comboBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.comboBox2 == null)
                return;

            if (this.selectedButton == null)
                return;
      
            ImageSource imageSource = null;
            ImageSourceConverter converter = new ImageSourceConverter();
            // When you set the button's ImageSource property, the button will display an image and its size will be equal to the value of the ImageSize property.
            switch (this.comboBox2.SelectedIndex)
            {
                case 0:
                    imageSource = converter.ConvertFromString("pack://application:,,/../Images/categorize.png") as ImageSource;
                    if (imageSource != null)
                    {
                        this.selectedButton.ImageSource = imageSource;
                    }
                    break;
                case 1:
                    imageSource = converter.ConvertFromString("pack://application:,,/../Images/mail.png") as ImageSource;
                    if (imageSource != null)
                    {
                        this.selectedButton.ImageSource = imageSource;
                    }
                    break;
                case 2:
                    imageSource = converter.ConvertFromString("pack://application:,,/../Images/note.png") as ImageSource;
                    if (imageSource != null)
                    {
                        this.selectedButton.ImageSource = imageSource;
                    }
                    break;
                case 3:
                    imageSource = converter.ConvertFromString("pack://application:,,/../Images/paste.png") as ImageSource;
                    if (imageSource != null)
                    {
                        this.selectedButton.ImageSource = imageSource;
                    }
                    break;
                case 4:
                    imageSource = converter.ConvertFromString("pack://application:,,/../Images/print.png") as ImageSource;
                    if (imageSource != null)
                    {
                        this.selectedButton.ImageSource = imageSource;
                    }
                    break;
            }
        }

        private void comboBox3_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.comboBox3 == null)
                return;

            if (this.selectedButton == null)
                return;

            // Set the selected button TextImageRelation property.

            switch (this.comboBox3.SelectedIndex)
            {
                case 0:
                    this.selectedButton.TextImageRelation = TextImageRelation.ImageAboveText;
                    this.selectedButton.HorizontalTextAlignment = System.Windows.HorizontalAlignment.Center;
                    this.selectedButton.VerticalTextAlignment = System.Windows.VerticalAlignment.Center;
                    this.selectedButton.HorizontalImageAlignment = System.Windows.HorizontalAlignment.Center;
                    this.selectedButton.VerticalImageAlignment = System.Windows.VerticalAlignment.Center;
                    break;
                case 1:
                    this.selectedButton.TextImageRelation = TextImageRelation.TextAboveImage;
                    this.selectedButton.HorizontalTextAlignment = System.Windows.HorizontalAlignment.Center;
                    this.selectedButton.VerticalTextAlignment = System.Windows.VerticalAlignment.Bottom;
                    this.selectedButton.HorizontalImageAlignment = System.Windows.HorizontalAlignment.Center;
                    this.selectedButton.VerticalImageAlignment = System.Windows.VerticalAlignment.Top;
                    break;
                case 2:
                    this.selectedButton.TextImageRelation = TextImageRelation.ImageBeforeText;
                    this.selectedButton.HorizontalTextAlignment = System.Windows.HorizontalAlignment.Center;
                    this.selectedButton.VerticalTextAlignment = System.Windows.VerticalAlignment.Center;
                    this.selectedButton.HorizontalImageAlignment = System.Windows.HorizontalAlignment.Center;
                    this.selectedButton.VerticalImageAlignment = System.Windows.VerticalAlignment.Center;
                    break;
                case 3:
                    this.selectedButton.TextImageRelation = TextImageRelation.TextBeforeImage;
                    this.selectedButton.HorizontalTextAlignment = System.Windows.HorizontalAlignment.Right;
                    this.selectedButton.VerticalTextAlignment = System.Windows.VerticalAlignment.Center;
                    this.selectedButton.HorizontalImageAlignment = System.Windows.HorizontalAlignment.Left;
                    this.selectedButton.VerticalImageAlignment = System.Windows.VerticalAlignment.Center;
                    break;
                case 4:
                    this.selectedButton.TextImageRelation = TextImageRelation.Overlay;
                    this.selectedButton.HorizontalTextAlignment = System.Windows.HorizontalAlignment.Center;
                    this.selectedButton.VerticalTextAlignment = System.Windows.VerticalAlignment.Center;
                    this.selectedButton.HorizontalImageAlignment = System.Windows.HorizontalAlignment.Center;
                    this.selectedButton.VerticalImageAlignment = System.Windows.VerticalAlignment.Center;
                    break;
            }
        }

        private void comboBox4_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // When you set the CornerRadius property of the button, its border's shape will be automatically changed.
            if (this.selectedButton != null)
            {
                this.selectedButton.CornerRadius = new CornerRadius(this.comboBox4.SelectedIndex);
            }
        }

        private void comboBox5_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.selectedButton == null)
                return;

            switch (this.comboBox5.SelectedIndex)
            {
                case 0:
                    this.selectedButton.ForegroundNormal = new SolidColorBrush(Colors.White);
                    break;
                case 1:
                    this.selectedButton.ForegroundNormal = new SolidColorBrush(Colors.Blue);
                    break;
                case 2:
                    this.selectedButton.ForegroundNormal = new SolidColorBrush(Colors.Red);
                    break;
                case 3:
                    this.selectedButton.ForegroundNormal = new SolidColorBrush(Color.FromArgb(255, 4, 34, 113));
                    break;
                case 4:
                    this.selectedButton.ForegroundNormal = new SolidColorBrush(Colors.Green);
                    break;
            }
        }

        private void comboBox6_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.selectedButton == null)
                return;

            switch (this.comboBox6.SelectedIndex)
            {
                case 0:
                    this.selectedButton.ForegroundHighlight = new SolidColorBrush(Colors.White);
                    break;
                case 1:
                    this.selectedButton.ForegroundHighlight = new SolidColorBrush(Colors.Blue);
                    break;
                case 2:
                    this.selectedButton.ForegroundHighlight = new SolidColorBrush(Colors.Red);
                    break;
                case 3:
                    this.selectedButton.ForegroundHighlight = new SolidColorBrush(Color.FromArgb(255, 4, 34, 113));
                    break;
                case 4:
                    this.selectedButton.ForegroundHighlight = new SolidColorBrush(Colors.Green);
                    break;
            }
        }

        private void comboBox7_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.selectedButton == null)
                return;

            switch (this.comboBox7.SelectedIndex)
            {
                case 0:
                    this.selectedButton.ForegroundPressed = new SolidColorBrush(Colors.White);
                    break;
                case 1:
                    this.selectedButton.ForegroundPressed = new SolidColorBrush(Colors.Blue);
                    break;
                case 2:
                    this.selectedButton.ForegroundPressed = new SolidColorBrush(Colors.Red);
                    break;
                case 3:
                    this.selectedButton.ForegroundPressed = new SolidColorBrush(Color.FromArgb(255, 4, 34, 113));
                    break;
                case 4:
                    this.selectedButton.ForegroundPressed = new SolidColorBrush(Colors.Green);
                    break;
            }
        }
    }
}
